/*
 * @Author      : ZhouQiJun
 * @Date        : 2025-08-06 23:06:40
 * @LastEditors : ZhouQiJun
 * @LastEditTime: 2025-11-06 11:09:21
 * @Description :
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import federation from '@originjs/vite-plugin-federation'

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  console.log({ mode })
  const remotePort = mode === 'development' ? 4173 : 4173
  return {
    plugins: [
      vue(),
      federation({
        name: 'host-app',
        remotes: {
          remote_app: `http://localhost:${remotePort}/assets/remoteEntry.js`
        },
        shared: ['vue', 'tdesign-vue-next']
      })
    ],
    build: {
      target: 'esnext'
    },
    preview: {
      port: 5173
    }
  }
})
